﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DTO;
using BUS;

namespace GUI
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private string sConnectionString;

        private void btn_login_Click(object sender, EventArgs e)
        {
            //string sConnectionString;
            sConnectionString = "Initial Catalog=" + txt_database.Text + "; ";
            sConnectionString += "Data Source=" + txt_serverIP.Text + "; ";
            sConnectionString += "Integrated Security = SSPI" + "; ";

            Connected.Conecter(sConnectionString);                                 

            this.Dispose();

            DangNhap dangNhapfrm = new DangNhap();

            dangNhapfrm.ShowDialog();

            //SqlConnection cnn = new SqlConnection(sConnectionString);

            //cnn.Open();

            //SqlCommand cmd = new SqlCommand();

            ////SqlTransaction tran;
            //cmd.Connection = cnn;

            //cmd.Transaction = cnn.BeginTransaction(IsolationLevel.ReadCommitted);

            //cmd.CommandText = "insert into NhanVien values('020', '123456', 'ABC', '3/1/1977 12:00:00 AM', 1, '004')";

            //cmd.ExecuteNonQuery();

            //cmd.Transaction.Commit();

            //cnn.Close();


        }

        private void btn_refresh_Click(object sender, EventArgs e)
        {
            txt_database.Text = null;
            txt_serverIP.Text = null;
        }
    }
}
